<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{data.title}}</block>
		</cu-custom>
		<view class="bg-white padding-xl">
			<view class="bg-gradual-yellow radius-lg-nobt">
				<view class="padding-sm bg-img">
					<view class="cu-list menu-avatar padding-top-xs comment user-card" @click="naviTo('lector/detail',{uid:data.lector.uid})">
						<view class="cu-item lg padding-bottom arrow">
							<view class="cu-avatar round xl border" :style="'background-image:url('+data.lector.cover+');'"></view>
							<view class="content">
								<view class="title"><text class="text-xxl text-cut">{{data.lector.name}}</text></view>
								<view class="text-cut text-lg text-content">
									{{data.lector.lector}}<text v-if="lectorid">(已认证)</text>
								</view>
							</view>
							<view class="action">
								<view class="text-lg"><text class="text-red">{{data.lector.collection}}</text>订阅</view>
							</view>
						</view>
					</view>
					<view class="flex details text-center text-black padding-sm padding-top-0 border-top">
						<view class="flex-sub" @click="naviTo('lector/income')">
							<view class="text-bold">{{data.incomes.today}}</view>
							<text>今日收入</text>
						</view>
						<view class="flex-sub" @click="naviTo('lector/income')">
							<view class="text-bold">{{data.incomes.total}}</view>
							<text>累计收入</text>
						</view>
						<view class="flex-sub" @click="naviTo('lector/lesson')">
							<view class="text-bold">{{data.lector.lessons}}</view>
							<text>课程总数</text>
						</view>
						<view class="flex-sub" @click="naviTo('lector/order')">
							<view class="text-bold">{{data.incomes.orders}}</view>
							<text>订单总数</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bg-white shadow-outside padding-top">
			<view class="cu-list grid col-3 no-border">
				<view class="cu-item" @click="naviTo('lector/lesson')">
					<view class="image">
						<image src="@/static/images/icon/lector_lesson.png" mode="aspectFit"></image>
					</view>
					<text>课程管理</text>
				</view>
				<view class="cu-item" @click="naviTo('lector/special')">
					<view class="image">
						<image src="@/static/images/icon/lector_special.png" mode="aspectFit"></image>
					</view>
					<text>专栏管理</text>
				</view>
				<view class="cu-item" @click="naviTo('lector/order')">
					<view class="image">
						<image src="@/static/images/icon/lector_order.png" mode="aspectFit"></image>
					</view>
					<text>订单管理</text>
				</view>
				<view class="cu-item" @click="naviTo('lector/apply')">
					<view class="image">
						<image src="@/static/images/icon/lector_verify.png" mode="aspectFit"></image>
					</view>
					<text>讲师认证</text>
				</view>
				<view class="cu-item" @click="naviTo('lector/income')">
					<view class="image">
						<image src="@/static/images/icon/lector_income.png" mode="aspectFit"></image>
					</view>
					<text>收益管理</text>
				</view>
				<view class="cu-item" @click="naviTo('lector/learner')">
					<view class="image">
						<image src="@/static/images/icon/lector_student.png" mode="aspectFit"></image>
					</view>
					<text>学员管理</text>
				</view>
				<view class="cu-item" @click="naviTo('lector/comment')">
					<view class="image">
						<image src="@/static/images/icon/lector_comment.png" mode="aspectFit"></image>
					</view>
					<text>评价管理</text>
				</view>
			</view>
		</view>
		<view class="text-center padding">
			<text class="text-gray">{{systemname}}讲师管理中心</text>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex'
	import core from "@/static/core.js"
	import store from '@/store/index.js'
	
	export default {
		computed: mapState(['hasLogin', 'lectorid']),
		data() {
			return {
				systemname:"在线教育平台",
				data:{
					title:"讲师中心",
					lector:{
						"uid": 0,
						"collection": 0,
						"lid": 0,
						"name": "0",
						"proportion": 0,
						"cover": "",
						"summary": "",
						"displayorder": 0,
						"nickname": "",
						"realname": "",
						"mobile": "",
						"gender": 0,
						"qq": "",
						"bio": "",
						"lector": "",
						"lproportion": 0,
						"aid": 0,
						"applytime": "",
						"state": "",
						"sex": "",
						"lessons": 0,
						"specials": 0
					},
					incomes:{
						today:0.00,
						total:0.00,
						orders:0
					}
				}
			}
		},
		onLoad() {
			
			this.systemname = this.systemname;
		},
		onShow() {
			if(!this.hasLogin){
				return core.navito('auth/index',{act:'login',forward:'lector/console'},1);
			}			
			// if(this.lectorid==0){
			// 	return core.navito('lector/apply',{},1);
			// }
			let lectorid = this.lectorid;
			this.initData('lector/console',{},function(res){
				if(res.lector.lid!=lectorid){
					store.commit('setlector',res.lector.lid);
				}								
				if(res.lector.lid==0){
					return core.navito('lector/apply',{},1);
				}
			});
		},
		onPullDownRefresh(){
			this.initData('lector/console',{},function(res){
				alert(res.lector.lid)
				if(res.lector.lid==0){
					return core.navito('lector/apply',{},1);
				}
			});
			uni.stopPullDownRefresh();
		},
		methods:{
			initData(route, data={}, callback=false){
				var that = this;
				core.get(route,function(res){
					// if(typeof(res.message)!='undefined' && typeof(res.type)!='undefined'){
					// 	return core.report(res);
					// }
					that.data = res;
					uni.setNavigationBarTitle({
						title:res.title
					});
					if(callback){
						callback(res);
					}
				},data);
			},
			naviTo(page,data={}){
				return core.navito(page,data);
			},
			unSupport(){
				return core.toast('敬请期待');
			}
		}
	}
</script>

<style>
page{background: #FFFFFF;}
.bg-gradual-yellow{background:linear-gradient(135deg,rgba(255,227,2,1) 0%,rgba(255,201,12,1) 100%);}
.bg-gradual-yellow .bg-img{background: url(@/static/images/bg_lector_card.png) no-repeat top right; background-size: 100% auto;}
.bg-gradual-yellow .cu-item{background: none; height: 80px;}
.bg-gradual-yellow .cu-item::after{border-bottom-color: #FFFFFF;}
.bg-gradual-yellow .cu-item .content .title{font-size: 1.06rem !important; font-weight: 600; color: #333333;}
.bg-gradual-yellow .cu-item .content{width: calc(100% - 350upx); left: 100px;}
.bg-gradual-yellow .cu-item .action{width: 150upx;}
.bg-gradual-yellow .cu-item .cu-avatar.xxl{width: 70px; height: 70px;}
.details.border-top::before{background: #FFDD8F;}
.details .text-bold{font-size: 1.01rem; margin-bottom: 10upx;}
.details .text-bold ~ text{color: #666666;}
.shadow-outside{box-shadow:0rem -0.08rem 0.53rem 0rem rgba(220,213,207,0.5); margin-top: -50upx;}
.shadow-outside .cu-item{margin-bottom: 15upx;}
.shadow-outside .cu-item .image{width: 2.67rem; height: 2.67rem; margin: 0 auto; margin-bottom: 0.4rem;}
.shadow-outside .cu-item .image image{max-height: 100%;}
</style>
